﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UFIDA.U9.Cust.XH.PlugBE.Model
{
    public class SOOrderModel
    {
        /// <summary>
        /// 销售订单
        /// </summary>
        /// <param name="m"></param>
        public SOOrderModel(UFIDA.U9.SM.SO.SO m)
        {

            this.DocumentType_Name = m.DocumentType.Name;
            this.DocNo = m.DocNo;
            this.BusinessDate = m.BusinessDate;
            this.Seller_Code = m.Seller.Code;

            this.Status = UFIDA.U9.PR.PurchaseRequest.PRStatusEnum.EnumRes.GetResource(m.Status.Name);
            this.ConfirmTerm_Name = m.ConfirmTerm?.Name;
            this.TC_Name = m.TC?.Name;
            this.AccountOrg_Name = m.AccountOrg?.Name;
            this.InvoiceOrg_Name = m.InvoiceOrg?.Name;

            this.Memo = m.Memo;
            this.CreatedBy = m.CreatedBy;
            this.CreatedOn = m.CreatedOn;
            this.Customer_Name = m.OrderBy.Customer.Name;
            this.Customer_FullName = m.DescFlexField.PrivateDescSeg2;


        }
        public string DocumentType_Name { get; set; }
        public string DocNo { get; set; }
        public DateTime BusinessDate { get; set; }
        public string Seller_Code { get; set; }
        public string Status { get; set; }

        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string ConfirmTerm_Name { get; set; }
        public string TC_Name { get; set; }

        public string AccountOrg_Name { get; set; }
        public string InvoiceOrg_Name { get; set; }
        public string Memo { get; set; }


        public string Customer_Name { get; set; }
        /// <summary>
        /// 终端客户
        /// </summary>
        public string Customer_FullName { get; set; }

    }

    public class SOOrderLineModel
    {
        public SOOrderLineModel(UFIDA.U9.SM.SO.SOLine m)
        {
            this.CustomerItemNo = m.CustomerItemNo;
            this.ItemCode = m.ItemInfo.ItemCode;
            this.ItemName = m.ItemInfo.ItemName;
            this.ItemSPECS = m.ItemInfo.ItemID.SPECS;
            this.PUUOM_Name = m.PU.Name;
            this.OrderByQtyPU = m.OrderByQtyPU;
            this.OrderPriceTC = m.OrderPriceTC;
            this.DiscountRate = m.DiscountRate;
            this.FinallyPriceTC = m.FinallyPriceTC;
            this.NetMoneyTC = m.NetMoneyTC;
            this.TaxMoneyAC = m.TaxMoneyAC;
            this.TaxRate = m.TaxRate;
            this.TotalMoneyAC = m.TotalMoneyAC;
            this.IsPromotionPresent = m.IsPromotionPresent;
            foreach (UFIDA.U9.SM.SO.SOShipline item in m.SOShiplines)
            {
                this.CommitDate = item.RequireDate;
            }
        }
        public string CustomerItemNo { get; set; }
        public string ItemCode { get; set; }
        public string ItemName { get; set; }
        public string ItemSPECS { get; set; }
        public string PUUOM_Name { get; set; }
        public decimal OrderByQtyPU { get; set; }
        public decimal OrderPriceTC { get; set; }
        public decimal DiscountRate { get; set; }
        public decimal FinallyPriceTC { get; set; }
        public decimal NetMoneyTC { get; set; }
        public decimal TaxMoneyAC { get; set; }
        public decimal TaxRate { get; set; }
        public decimal TotalMoneyAC { get; set; }

        public DateTime CommitDate { get; set; }
        
        public bool IsPromotionPresent { get; set; }


    }
}
